#include <stdio.h>

int main ()
{
	int n, k;
	int i = 1, t, sum, amount = 0;
	scanf("%d %d", &n, &k);
	if (n < 0) {
		n = -n;
		k = -k;
		i = -1;
	}

	while (i<=n) {
		t = i;
		sum = 0;
		do {
			sum += t % 10;
			t = t / 10;
		} while (t > 0);

		if (sum % k == 0) {
			amount++;
		}
		i++;
		//printf("i=%3d, t=%3d, sum=%3d, amount=%3d\n", i,t,sum,amount);
	}

	printf("%d\n", amount);
	return 0;
}
